<template>
	<view class="white nav-box" :class="'bg-'+bgHeader">
		<view :style="{ height : statusBarHeight + 'px'}"></view>
		<view :style="{ height : titleBarHeight + 'px'}">
			<!--#ifndef MP-WEIXIN-->
			<view class="item-box nav-back" :class="leftArrow === false ?'nav-back-none':''"  @click="goBack"></view>
			<!--#endif-->
			<!-- <view class="item-box nav-text" :class="leftArrow === true ?'nav-text-black':'' " :style="{lineHeight:titleBarHeight + 'px',height:titleBarHeight + 'px'}">
				
				v-if="leftArrow === true"
				<text class="item-text ellipsis">{{textContent}}</text>
				
				<text class="item-text item-text-other ellipsis">{{textContent}}</text>
				
			</view> -->
			<!--#ifdef MP-WEIXIN-->
			<view class="item-box nav-text nav-text-weixin" :class="leftArrow === true ?'nav-text-black':'' " :style="{lineHeight:titleBarHeight + 'px',height:titleBarHeight + 'px'}">				
				<text class="item-text ellipsis f-32" :style="{paddingLeft: paddingLeft + 'rpx'}">{{textContent}}</text>
			</view>
			<!--#endif-->
			<!--#ifndef MP-WEIXIN-->
				<view class="item-box nav-text nav-text-other text-center" :class="leftArrow === true ?'nav-text-black':'' " :style="{lineHeight:titleBarHeight + 'px',height:titleBarHeight + 'px'}">
					<text class="item-text ellipsis f-32">{{textContent}}</text>
				</view>
			<!--#endif-->
		</view>
	</view>
</template>

<script>
export default {
	name: 'common-top',
	props: {
		bgHeader:{
			type: String,
			default: 'blue'
		},
		textContent: {
			type: String,
			default: '达川招商局'
		},
		leftArrow: { //是否禁用
			type: Boolean,
			default: false,
		},
		paddingLeft:{
		  type: Number,
		  default: 30
		}
	},
  data() {
    return {
		titleBarHeight:'',
		statusBarHeight:'',
		menuButtonLeft:''
    }
  },
  mounted() {
	uni.getSystemInfo({ //获取系统信息
		success: res => {
			let menuButtonObject = uni.getMenuButtonBoundingClientRect(); //获取菜单按钮（右上角胶囊按钮）的布局位置信息。坐标信息以屏幕左上角为原点。
			// #ifndef H5 || APP-PLUS || MP-ALIPAY
				let navHeight = menuButtonObject.height + (menuButtonObject.top - res.statusBarHeight) * 2; //导航栏高度=菜单按钮高度+（菜单按钮与顶部距离-状态栏高度）*2
				let menuButtonLeft = menuButtonObject.top
				// 导航栏（胶囊）高度
				this.titleBarHeight = navHeight;
				//  状态栏（顶部）高度
				this.statusBarHeight = res.statusBarHeight
				// console.log(this.titleBarHeight);
				// console.log(this.statusBarHeight);
				// console.log(this.menuButtonLeft,'左')
			// #endif
			// #ifdef  H5 || APP-PLUS
				this.statusBarHeight =  res.statusBarHeight
				this.titleBarHeight = 40
			// #endif
		},
		fail(err) {
			console.log(err);
		}
	})
  },
  methods: {
	  goBack(){
		  let pages = getCurrentPages()//获取所有页面栈的实例列表
		  let nowPage = pages[ pages.length - 1 ] //当前页面的实例
		  let prevPage = pages[ pages.length - 2 ] //上一个页面的实例
		  prevPage.$vm.status = false //更改上一个页面的数据
		  uni.navigateBack({
			  delta:1  //返回上一页
		  })
	  }
  }
}
</script>

<style>
</style>